| 1 | ############################################################# |
| 2 | # (c) 2021 Aaron Taylor <ataylor at subgeniuskitty dot com> # |
| 3 | # See LICENSE.txt file for copyright and license details. # |
| 4 | ############################################################# |
| 5 | |
| 6 | |
| 7 | ################################################################################ |
| 8 | # Configuration |
| 9 | ################################################################################ |
| 10 | |
| 11 | # The below settings work on FreeBSD. Other UNIX-like systems should only |
| 12 | # require minor tweaks (e.g. LIB_PATH on Debian should be /usr/lib/ rather than |
| 13 | # /usr/local/lib/ and the compiler is gcc rather than cc). |
| 14 | CC = cc |
| 15 | CC_FLAGS = -Wall -pedantic -std=c99 |
| 16 | INC_PATH = -I../../screenhack/ -I/usr/local/include/ |
| 17 | LIB_PATH = -L/usr/local/lib/ |
| 18 | LIBS = -lm -lX11 -lXt |
| 19 | |
| 20 | # Many of the X-related header files contain named variadic macros. Suppress |
| 21 | # that warning so that we can enable -pedantic C89 compliance for our own code. |
| 22 | CC_FLAGS += -Wno-variadic-macros |
| 23 | |
| 24 | # Binary literals are not part of C, yet are used liberally in NEDsim. |
| 25 | CC_FLAGS += -Wno-gnu-binary-literal |
| 26 | |
| 27 | # These flags are normally set in config.h which is generated by the autoconf |
| 28 | # script as the initial step of the xscreensaver build process. The flags |
| 29 | # enable/disable code in the various screenhack library files. When compiling |
| 30 | # elsewhere than FreeBSD, these flags will likely need to be changed. If |
| 31 | # you're having trouble determing the correct flags to use, try running |
| 32 | # './configure' in an xscreensaver source tree and examining the generated |
| 33 | # config.h file. |
| 34 | DEFINES = -DGETTIMEOFDAY_TWO_ARGS -DHAVE_UNISTD_H |
| 35 | |
| 36 | # Since we're only building standalone hacks (i.e. building outside the |
| 37 | # xscreensaver tree/process) for testing and will later integrate them into the |
| 38 | # xscreensaver source tree, for now we simply slurp up all the C files that |
| 39 | # comprise the screenhack library and link them directly into the binary. |
| 40 | SCREENHACK_SRC != ls -1 ../../screenhack/*.c |
| 41 | |
| 42 | # Create NED_OBJ containing a list of object files with embedded NED1 machine |
| 43 | # code which should be linked to the NEDsim binary. |
| 44 | .SUFFIXES: .ned_asm |
| 45 | NED_SRC != ls ned_programs/*.ned_asm |
| 46 | NED_OBJ := $(NED_SRC:.ned_asm=.o) |
| 47 | |
| 48 | ################################################################################ |
| 49 | # Targets |
| 50 | ################################################################################ |
| 51 | |
| 52 | all: embed |
| 53 | @$(CC) $(CC_FLAGS) $(DEFINES) $(INC_PATH) $(LIB_PATH) $(LIBS) \ |
| 54 | -o NEDsim NEDsim.c simulator.c $(SCREENHACK_SRC) $(NED_OBJ) |
| 55 | |
| 56 | embed: |
| 57 | @cd ned_programs && make all && cd .. |
| 58 | |
| 59 | clean: |
| 60 | @cd ned_programs && make clean && cd .. |
| 61 | @rm -f NEDsim NEDsim.core *.o |
| 62 | |
| 63 | run: clean all |
| 64 | @echo "" |
| 65 | @echo "######################" |
| 66 | @echo "# Press 'q' to exit. #" |
| 67 | @echo "######################" |
| 68 | @echo "" |
| 69 | @./NEDsim |