modernize configure
authorMischa POSLAWSKY <netris@shiar.org>
Tue, 27 Feb 2007 15:51:27 +0000 (16:51 +0100)
committerMischa POSLAWSKY <netris@shiar.org>
Tue, 27 Feb 2007 15:51:27 +0000 (16:51 +0100)
Static Makefile; Configure-dependant variables in config.mak
Cleanness and legibility should be evident :)

.gitignore
Configure
Makefile [new file with mode: 0644]

index 7a8b84c94401f89cf51e1f199711c512c105e9fd..7f0468b811c9b9c026910bf266e1af58a9898462 100644 (file)
@@ -1,6 +1,5 @@
-Makefile
+config.mak
 config.h
-version.c
 *.o
 netris
 netrisserver
index b3ee7018530a13306a46f73cc89c02fee48d1503..2ea6057a958342a79cddcb4c1947365156ab570c 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -135,82 +135,21 @@ fi
 
 rm -f test.c test.o a.out
 
-SOURCES="game- curses- board- util- inet-"
-SRCS="`echo $SOURCES | sed -e s/-/.c/g`"
-OBJS="`echo $SOURCES | sed -e s/-/.o/g`"
-SSOURCES="server- util-"
-SSRCS="`echo $SSOURCES | sed -e s/-/.c/g`"
-SOBJS="`echo $SSOURCES | sed -e s/-/.o/g`"
-
-DISTFILES="README FAQ INSTALL COPYING VERSION TODO ChangeLog Configure netris.h"
-DISTFILES="$DISTFILES $SRCS server.c"
-
-echo "Creating Makefile"
-sed -e "s/-LFLAGS-/$LFLAGS/g" -e "s/-OBJS-/$OBJS/g" \
-       -e "s/-SOBJS-/$SOBJS/g" -e "s/-DISTFILES-/$DISTFILES/g" \
-       -e "s/-COPT-/$COPT/g" -e "s/-CEXTRA-/$CEXTRA/g" \
-       -e "s/-LEXTRA-/$LEXTRA/g" -e "s/-CC-/$CC/g" \
-       << "END" > Makefile
-#
-# Automatically generated by ./Configure -- DO NOT EDIT!
-#
-
-CC = -CC-
-COPT = -COPT-
-CEXTRA = -CEXTRA-
-LEXTRA = -LEXTRA-
-LFLAGS = -LEXTRA- -LFLAGS-
-CFLAGS = $(CEXTRA) $(COPT)
-
-PROG = netris
-SPROG = netrisserver
-HEADERS = netris.h
-OBJS = -OBJS-
-SOBJS = -SOBJS-
-DISTFILES = -DISTFILES-
-
-all: Makefile config.h $(PROG) $(SPROG)
-
-$(PROG): $(OBJS)
-       $(CC) -o $(PROG) $(OBJS) $(LFLAGS) $(CFLAGS)
-
-$(SPROG): $(SOBJS)
-       $(CC) -o $(SPROG) $(SOBJS) $(LFLAGS) $(CFLAGS)
-
-.c.o:
-       $(CC) $(CFLAGS) -c $<
-
-Makefile config.h: Configure
-       @echo "Makefile and/or config.h is out of date"
-       @echo "Run ./Configure now"
-       @false
-
-dist: $(DISTFILES)
-       @vers=`cat VERSION`; \
-       dir="netris-$$vers"; \
-       echo "Creating $$dir directory"; \
-       rm -rf $$dir; \
-       mkdir $$dir; \
-       cp $(DISTFILES) $$dir; \
-       chmod 755 $$dir; \
-       chmod 644 $$dir/*; \
-       chmod 755 $$dir/Configure; \
-       echo "Creating $$dir.tar.gz"; \
-       tar -cvzof $$dir.tar.gz $$dir
-
-clean:
-       rm -f $(PROG) $(OBJS) $(SPROG) $(SOBJS) a.out
-
-cleandir: clean
-       rm -f Makefile config.h
-
+echo "Creating config.mak"
+cat > config.mak << END
+### Automatically generated by ./Configure ###
+
+CC = $CC
+COPT = $COPT
+CEXTRA = $CEXTRA
+LEXTRA = $LEXTRA
+LFLAGS = $LEXTRA $LFLAGS
+CFLAGS = \$(CEXTRA) \$(COPT)
 END
 
 echo "Creating config.h"
 cat << END > config.h
-/*
- * Automatically generated by ./Configure -- DO NOT EDIT!
- */
+/*** Automatically generated by ./Configure ***/
 
 END
 
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..ba18908
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,54 @@
+# Netris Makefile
+
+include config.mak
+
+VERSION = ?
+
+PROG = netris
+SPROG = netrisserver
+HEADERS = netris.h
+
+SRCS = game.c curses.c board.c util.c inet.c
+SSRCS = server.c util.c
+
+OBJS = $(SRCS:.c=.o)
+SOBJS = $(SSRCS:.c=.o)
+
+DISTFILES = README FAQ INSTALL COPYING TODO CHANGES \
+       Configure Makefile netris.h \
+       $(SRCS) server.c \
+
+all: Makefile config.h $(PROG) $(SPROG)
+
+$(PROG): $(OBJS)
+       $(CC) -o $(PROG) $(OBJS) $(LFLAGS) $(CFLAGS)
+
+$(SPROG): $(SOBJS)
+       $(CC) -o $(SPROG) $(SOBJS) $(LFLAGS) $(CFLAGS)
+
+.c.o:
+       $(CC) $(CFLAGS) -c $<
+
+Makefile config.h: Configure
+       @echo "Makefile and/or config.h is out of date"
+       @echo "Run ./Configure now"
+       @false
+
+dist: $(DISTFILES)
+       @dir="netris-$(VERSION)"; \
+       echo "Creating $$dir directory"; \
+       rm -rf $$dir; \
+       mkdir $$dir; \
+       cp $(DISTFILES) $$dir; \
+       chmod 755 $$dir; \
+       chmod 644 $$dir/*; \
+       chmod 755 $$dir/Configure; \
+       echo "Creating $$dir.tar.gz"; \
+       tar -cvzof $$dir.tar.gz $$dir
+
+clean:
+       rm -f $(PROG) $(OBJS) $(SPROG) $(SOBJS) a.out
+
+cleandir: clean
+       rm -f config.mak config.h
+