Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cmake support #39

Closed
wants to merge 4 commits into from
Closed

Add cmake support #39

wants to merge 4 commits into from

Conversation

JiantaoFu
Copy link

I have validate this in both osx and linux, with the following options: -DWEXT -DPCAP -DLIBNL, also fix some compile errors and warnings.

@@ -126,6 +126,7 @@ struct list_node *list_check_node(const struct list_node *n,
* Example:
* static LIST_HEAD(my_global_list);
*/
#undef LIST_HEAD
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove warning here:

./ccan/list/list.h:129:9: warning: 'LIST_HEAD' macro redefined [-Wmacro-redefined]
#define LIST_HEAD(name)
^
/usr/include/sys/queue.h:417:9: note: previous definition is here
#define LIST_HEAD(name, type)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not just #undef a macro. The question is why is sys/queue.h included?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#include <sys/queue.h> /* get TAILQ macros */
"/usr/include/net/if_var.h" [readonly] 235L, 9394C

if.h 108 #include <net/if_var.h>

It comes from if.h which includes if_var.h

@JiantaoFu
Copy link
Author

On OSX, using Makefile still having error, i just don't know how to fix that

make PCAP=1 WEXT=0 LIBNL=0

#include <ccan/str/str.h>
^
1 error generated.
In file included from ifctrl-dummy.c:21:
In file included from ./main.h:27:
./ccan/list/list.h:7:10: fatal error: 'ccan/str/str.h' file not found
#include <ccan/str/str.h>
...
duplicate symbol _ifctrl_flags in:
ifctrl-ioctl.o
ifctrl-dummy.o

@br101
Copy link
Owner

br101 commented Nov 13, 2015

I appreciate your work but, sorry, I can not merge this. I will fix up the errors I introduced while extending channels recently. Please check back soon.

Also I'm not convinced that using cmake is necessary for a better solution. What exactly do you need it for?

@br101 br101 closed this Nov 13, 2015
@br101
Copy link
Owner

br101 commented Nov 13, 2015

I pushed my changes. Can you please try again? Please compile with make LIBNL=0 PCAP=1

@JiantaoFu
Copy link
Author

Still having some errors below:

JIANFU-M-M0AH:horst jeromy$ make LIBNL=0 PCAP=1
gcc -MM average.c capture-pcap.c channel.c conf_options.c control.c display-channel.c display-essid.c display-filter.c display-help.c display-history.c display-main.c display-spectrum.c display-statistics.c display.c essid.c ieee80211_util.c ifctrl-ioctl.c listsort.c main.c network.c node.c protocol_parser.c protocol_parser_wlan.c radiotap/radiotap.c util.c wlan_util.c ifctrl-dummy.c >.objdeps.mk
In file included from channel.c:22:
In file included from ./main.h:26:
./ccan/list/list.h:7:10: fatal error: 'ccan/str/str.h' file not found
#include <ccan/str/str.h>
^
1 error generated.
In file included from conf_options.c:25:
In file included from ./main.h:26:
./ccan/list/list.h:7:10: fatal error: 'ccan/str/str.h' file not found
#include <ccan/str/str.h>
^
1 error generated.
In file included from control.c:27:
In file included from ./main.h:26:
./ccan/list/list.h:7:10: fatal error: 'ccan/str/str.h' file not found
#include <ccan/str/str.h>
^
1 error generated.
In file included from display-channel.c:25:
In file included from ./main.h:26:
./ccan/list/list.h:7:10: fatal error: 'ccan/str/str.h' file not found
#include <ccan/str/str.h>
^
1 error generated.
In file included from display-essid.c:25:
In file included from ./main.h:26:
./ccan/list/list.h:7:10: fatal error: 'ccan/str/str.h' file not found
#include <ccan/str/str.h>
^
1 error generated.
In file included from display-filter.c:25:
In file included from ./main.h:26:
./ccan/list/list.h:7:10: fatal error: 'ccan/str/str.h' file not found
#include <ccan/str/str.h>
^
1 error generated.
In file included from display-help.c:25:
In file included from ./main.h:26:
./ccan/list/list.h:7:10: fatal error: 'ccan/str/str.h' file not found
#include <ccan/str/str.h>
^
1 error generated.
In file included from display-history.c:25:
In file included from ./main.h:26:
./ccan/list/list.h:7:10: fatal error: 'ccan/str/str.h' file not found
#include <ccan/str/str.h>
^
1 error generated.
In file included from display-main.c:26:
In file included from ./main.h:26:
./ccan/list/list.h:7:10: fatal error: 'ccan/str/str.h' file not found
#include <ccan/str/str.h>
^
1 error generated.
In file included from display-spectrum.c:25:
In file included from ./main.h:26:
./ccan/list/list.h:7:10: fatal error: 'ccan/str/str.h' file not found
#include <ccan/str/str.h>
^
1 error generated.
In file included from display-statistics.c:25:
In file included from ./main.h:26:
./ccan/list/list.h:7:10: fatal error: 'ccan/str/str.h' file not found
#include <ccan/str/str.h>
^
1 error generated.
In file included from display.c:31:
In file included from ./main.h:26:
./ccan/list/list.h:7:10: fatal error: 'ccan/str/str.h' file not found
#include <ccan/str/str.h>
^
1 error generated.
In file included from essid.c:23:
In file included from ./main.h:26:
./ccan/list/list.h:7:10: fatal error: 'ccan/str/str.h' file not found
#include <ccan/str/str.h>
^
1 error generated.
In file included from ieee80211_util.c:23:
In file included from ./main.h:26:
./ccan/list/list.h:7:10: fatal error: 'ccan/str/str.h' file not found
#include <ccan/str/str.h>
^
1 error generated.
In file included from listsort.c:46:
./ccan/list/list.h:7:10: fatal error: 'ccan/str/str.h' file not found
#include <ccan/str/str.h>
^
1 error generated.
In file included from main.c:32:
In file included from ./main.h:26:
./ccan/list/list.h:7:10: fatal error: 'ccan/str/str.h' file not found
#include <ccan/str/str.h>
^
1 error generated.
In file included from network.c:30:
In file included from ./main.h:26:
./ccan/list/list.h:7:10: fatal error: 'ccan/str/str.h' file not found
#include <ccan/str/str.h>
^
1 error generated.
In file included from node.c:24:
In file included from ./main.h:26:
./ccan/list/list.h:7:10: fatal error: 'ccan/str/str.h' file not found
#include <ccan/str/str.h>
^
1 error generated.
In file included from protocol_parser.c:31:
In file included from ./main.h:26:
./ccan/list/list.h:7:10: fatal error: 'ccan/str/str.h' file not found
#include <ccan/str/str.h>
^
1 error generated.
In file included from protocol_parser_wlan.c:30:
In file included from ./main.h:26:
./ccan/list/list.h:7:10: fatal error: 'ccan/str/str.h' file not found
#include <ccan/str/str.h>
^
1 error generated.
In file included from wlan_util.c:20:
In file included from ./main.h:26:
./ccan/list/list.h:7:10: fatal error: 'ccan/str/str.h' file not found
#include <ccan/str/str.h>
^
1 error generated.
In file included from ifctrl-dummy.c:21:
In file included from ./main.h:26:
./ccan/list/list.h:7:10: fatal error: 'ccan/str/str.h' file not found
#include <ccan/str/str.h>
^
1 error generated.
echo '-std=gnu99 -Wall -Wextra -g -I. -DDO_DEBUG -DPCAP' | cmp -s - .buildflags || echo '-std=gnu99 -Wall -Wextra -g -I. -DDO_DEBUG -DPCAP' > .buildflags
cc -std=gnu99 -Wall -Wextra -g -I. -DDO_DEBUG -DPCAP -c -o average.o average.c
cc -std=gnu99 -Wall -Wextra -g -I. -DDO_DEBUG -DPCAP -c -o capture-pcap.o capture-pcap.c
cc -std=gnu99 -Wall -Wextra -g -I. -DDO_DEBUG -DPCAP -c -o channel.o channel.c
cc -std=gnu99 -Wall -Wextra -g -I. -DDO_DEBUG -DPCAP -c -o conf_options.o conf_options.c
cc -std=gnu99 -Wall -Wextra -g -I. -DDO_DEBUG -DPCAP -c -o display-channel.o display-channel.c
cc -std=gnu99 -Wall -Wextra -g -I. -DDO_DEBUG -DPCAP -c -o display-filter.o display-filter.c
cc -std=gnu99 -Wall -Wextra -g -I. -DDO_DEBUG -DPCAP -c -o display-main.o display-main.c
cc -std=gnu99 -Wall -Wextra -g -I. -DDO_DEBUG -DPCAP -c -o display-spectrum.o display-spectrum.c
cc -std=gnu99 -Wall -Wextra -g -I. -DDO_DEBUG -DPCAP -c -o display.o display.c
cc -std=gnu99 -Wall -Wextra -g -I. -DDO_DEBUG -DPCAP -c -o ieee80211_util.o ieee80211_util.c
cc -std=gnu99 -Wall -Wextra -g -I. -DDO_DEBUG -DPCAP -c -o ifctrl-ioctl.o ifctrl-ioctl.c
cc -std=gnu99 -Wall -Wextra -g -I. -DDO_DEBUG -DPCAP -c -o main.o main.c
In file included from main.c:32:
In file included from ./main.h:26:
./ccan/list/list.h:129:9: warning: 'LIST_HEAD' macro redefined [-Wmacro-redefined]
#define LIST_HEAD(name)
^
/usr/include/sys/queue.h:417:9: note: previous definition is here
#define LIST_HEAD(name, type)
^
main.c:229:52: warning: format specifies type 'long' but the argument has type 'darwin_suseconds_t' (aka 'int') [-Wformat]
i += snprintf(buf + i, sizeof(buf) - i, ".%06ld", the_time.tv_usec);
~~~~~ ^~~~~~~~~~~~~~~~
%06d
/usr/include/secure/_stdio.h:57:62: note: expanded from macro 'snprintf'
__builtin___snprintf_chk (str, len, 0, __darwin_obsz(str), __VA_ARGS
)
^
2 warnings generated.
cc -std=gnu99 -Wall -Wextra -g -I. -DDO_DEBUG -DPCAP -c -o network.o network.c
cc -std=gnu99 -Wall -Wextra -g -I. -DDO_DEBUG -DPCAP -c -o node.o node.c
cc -std=gnu99 -Wall -Wextra -g -I. -DDO_DEBUG -DPCAP -c -o protocol_parser.o protocol_parser.c
cc -std=gnu99 -Wall -Wextra -g -I. -DDO_DEBUG -DPCAP -c -o protocol_parser_wlan.o protocol_parser_wlan.c
cc -std=gnu99 -Wall -Wextra -g -I. -DDO_DEBUG -DPCAP -c -o util.o util.c
cc -std=gnu99 -Wall -Wextra -g -I. -DDO_DEBUG -DPCAP -c -o wlan_util.o wlan_util.c
cc -std=gnu99 -Wall -Wextra -g -I. -DDO_DEBUG -DPCAP -c -o ifctrl-dummy.o ifctrl-dummy.c
cc -o horst average.o capture-pcap.o channel.o conf_options.o control.o display-channel.o display-essid.o display-filter.o display-help.o display-history.o display-main.o display-spectrum.o display-statistics.o display.o essid.o ieee80211_util.o ifctrl-ioctl.o listsort.o main.o network.o node.o protocol_parser.o protocol_parser_wlan.o radiotap/radiotap.o util.o wlan_util.o ifctrl-dummy.o -lncurses -lm -lpcap

@JiantaoFu
Copy link
Author

It's fine it's not get merged, it's a little bit over weight.
i'm using this on osx, and prefer generate xcode project for editing, and happened to succeed in compiling the code using cmake. That is the reason.

Thanks!

@br101
Copy link
Owner

br101 commented Nov 14, 2015

So, first, the errors you see come from the automatic dependency generation, which is not strictly necessary. As you see, later you get some warnings but the program compiles fine.

  1. gcc -MM average.c capture-pcap.c channel.c conf_options.c control.c display-channel.c display-essid.c display-filter.c display-help.c display-history.c display-main.c display-spectrum.c display-statistics.c display.c essid.c ieee80211_util.c ifctrl-ioctl.c listsort.c main.c network.c node.c protocol_parser.c protocol_parser_wlan.c radiotap/radiotap.c util.c wlan_util.c ifctrl-dummy.c does not find ccan/str/str.h. It does on Linux, but maybe you need to pass it an additional -I. option? Please try.

  2. LIST_HEAD is just a warning but I prefer to fix warnings. As we don't use LIST_HEAD in horst, I suppose we can undef it, but better not touch the code in the ccan directory (it's a kind of library) and undef it in main.h? I'll also see if newer ccan code handles that better.

  3. I'm surprised that xcode does not support Makefiles but anyways, I'm also not checking in my kdevelop project files ;)

@JiantaoFu
Copy link
Author

add -I. works, thanks! BTW, I've added ifctrl-osx.m, i don't figure out how to change makefile yet, i've compiled using cmake and it seems to work now.

JiantaoFu@ecd23f2

@fuji246
Copy link

fuji246 commented Nov 25, 2015

Hi, i have some changes and some comments, also questions here: JiantaoFu@0c0bf9f#diff-e460e33e58be499632b5d424bc9d1127R229, could you help take a look, thanks

@br101
Copy link
Owner

br101 commented Nov 26, 2015

Hi! I have added my comments, but it's a bit hard to review your stuff because you mix everything together. Better to make one commit for each and explain the issue well in the commit log... For example the ++new_idx; thing is a bugfix which is completely independent of the rest, and for which it would be good to send a separate pull request for. Now I have added that to horst already, thanks to your finding! Thanks! Also I recommend you should rebase (re-apply your changes) on top of the latest horst git. BTW are you JiantaoFu, Jeromy or fuji246, or are you several people... ;)

@fuji246
Copy link

fuji246 commented Nov 28, 2015

Yeah, those are all me. I've submitted another pull request for osx support

@fuji246
Copy link

fuji246 commented Nov 28, 2015

BTW, there is still another bug in channel.c

diff --git a/channel.c b/channel.c
index 7e8108e..6812f7b 100644
--- a/channel.c
+++ b/channel.c
@@ -230,6 +230,7 @@ channel_auto_change(void)
channel_get_chan(new_idx) > conf.channel_max))
new_idx = 0;

  •                   max_width = channel_get_band_from_idx(new_idx).max_chan_width;
                    ret = channel_change(new_idx, max_width, conf.channel_ht40plus);
    

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants