diff options
author | LAN-TW <lantw44@gmail.com> | 2013-11-16 20:35:26 +0800 |
---|---|---|
committer | LAN-TW <lantw44@gmail.com> | 2013-11-16 20:35:26 +0800 |
commit | 64709def2a772a82b9130c6f73c6774bcc29bf5d (patch) | |
tree | 0b40ba74e9afc1a6bf222ab26817e29375ea03ae /hw2 | |
parent | 8018ec1fed3400d46d2de89236c5c9397deadc8f (diff) | |
download | sp2013-64709def2a772a82b9130c6f73c6774bcc29bf5d.tar sp2013-64709def2a772a82b9130c6f73c6774bcc29bf5d.tar.gz sp2013-64709def2a772a82b9130c6f73c6774bcc29bf5d.tar.bz2 sp2013-64709def2a772a82b9130c6f73c6774bcc29bf5d.tar.lz sp2013-64709def2a772a82b9130c6f73c6774bcc29bf5d.tar.xz sp2013-64709def2a772a82b9130c6f73c6774bcc29bf5d.tar.zst sp2013-64709def2a772a82b9130c6f73c6774bcc29bf5d.zip |
HW2: 為交作業做準備
Diffstat (limited to 'hw2')
-rw-r--r-- | hw2/Makefile.am | 5 | ||||
-rw-r--r-- | hw2/Makefile.simple | 37 | ||||
-rw-r--r-- | hw2/configure.ac | 2 | ||||
-rw-r--r-- | hw2/xwrap.h | 1 |
4 files changed, 44 insertions, 1 deletions
diff --git a/hw2/Makefile.am b/hw2/Makefile.am index d4fd275..d17868c 100644 --- a/hw2/Makefile.am +++ b/hw2/Makefile.am @@ -1,4 +1,4 @@ -EXTRA_DIST = README.txt +EXTRA_DIST = Makefile.simple README.txt bin_PROGRAMS = big_judge judge player noinst_LIBRARIES = libsphw2.a libsphw2_a_SOURCES = xwrap.c xwrap.h logger.c logger.h @@ -9,6 +9,9 @@ judge_LDADD = $(top_builddir)/libsphw2.a player_SOURCES = player.c player_LDADD = $(top_builddir)/libsphw2.a +dist-hook: + cp -a $(distdir)/Makefile.simple $(distdir)/Makefile + submit_tarball_name=SPHW2_b01902062.tar.gz submit_dir_name=b01902062 diff --git a/hw2/Makefile.simple b/hw2/Makefile.simple new file mode 100644 index 0000000..cdf5445 --- /dev/null +++ b/hw2/Makefile.simple @@ -0,0 +1,37 @@ +# Programs +CC= c99 +RM= rm -f + +# Internal flags +SP_CFLAGS= -D_POSIX_C_SOURCE=200809L -D_BSD_SOURCE $(CFLAGS) +SP_LIBS= $(LDFLAGS) + +# Let user to override these variables +CFLAGS= -Wall -pipe -O2 +LDFLAGS= + +# Build dependencies +all_tasks= big_judge judge player +big_judge_objs= xwrap.o logger.o big_judge.o +judge_objs= xwrap.o logger.o judge.o +player_objs= xwrap.o logger.o player.o + +# Phony target +.PHONY: all clean auto +auto: + if [ ! -f configure ]; then autoreconf -iv; fi; ./configure && make +all: $(all_tasks) +clean: + $(RM) $(all_tasks) $(big_judge_objs) $(judge_objs) $(player_objs) + +# Suffix rules +.SUFFIXES: .c.o +.c.o: + $(CC) $(SP_CFLAGS) -c $< -o $@ + +big_judge: $(big_judge_objs) + $(CC) $(SP_CFLAGS) $(big_judge_objs) -o $@ $(SP_LDFLAGS) +judge: $(judge_objs) + $(CC) $(SP_CFLAGS) $(judge_objs) -o $@ $(SP_LDFLAGS) +player: $(player_objs) + $(CC) $(SP_CFLAGS) $(player_objs) -o $@ $(SP_LDFLAGS) diff --git a/hw2/configure.ac b/hw2/configure.ac index 24fdbf9..a6b6a1e 100644 --- a/hw2/configure.ac +++ b/hw2/configure.ac @@ -14,9 +14,11 @@ AC_CANONICAL_BUILD AH_TEMPLATE([OS_IS_LINUX]) AH_TEMPLATE([OS_IS_FREEBSD]) AH_TEMPLATE([_WITH_GETLINE]) +AH_TEMPLATE([_BSD_SOURCE]) case "$host_os" in *linux*) AC_DEFINE([OS_IS_LINUX], [1]) + AC_DEFINE([_BSD_SOURCE]) ;; *freebsd*) AC_DEFINE([OS_IS_FREEBSD], [1]) diff --git a/hw2/xwrap.h b/hw2/xwrap.h index 05504c3..fb5f1ef 100644 --- a/hw2/xwrap.h +++ b/hw2/xwrap.h @@ -3,6 +3,7 @@ #include <stdbool.h> #include <stdlib.h> +#include <sys/types.h> #define STATIC_STRLEN(x) (sizeof(x)/sizeof(char) - 1) #define ARRAY_LEN(x,t) (sizeof(x)/sizeof(t)) |