Added ability to directly embed NED programs in NEDsim binary for runtime execution.
[screensavers] / hacks / NEDsim / Makefile
CommitLineData
8ab082d8
AT
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).
14CC = cc
15CC_FLAGS = -Wall -pedantic -std=c99
16INC_PATH = -I../../screenhack/ -I/usr/local/include/
17LIB_PATH = -L/usr/local/lib/
18LIBS = -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.
22CC_FLAGS += -Wno-variadic-macros
23
24# Binary literals are not part of C, yet are used liberally in NEDsim.
25CC_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.
34DEFINES = -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.
40SCREENHACK_SRC != ls -1 ../../screenhack/*.c
41
b73247cf
AT
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
45NED_SRC != ls ned_programs/*.ned_asm
46NED_OBJ := $(NED_SRC:.ned_asm=.o)
47
8ab082d8
AT
48################################################################################
49# Targets
50################################################################################
51
b73247cf
AT
52all: embed
53 @$(CC) $(CC_FLAGS) $(DEFINES) $(INC_PATH) $(LIB_PATH) $(LIBS) \
54 -o NEDsim NEDsim.c simulator.c $(SCREENHACK_SRC) $(NED_OBJ)
55
56embed:
57 @cd ned_programs && make all && cd ..
8ab082d8
AT
58
59clean:
b73247cf
AT
60 @cd ned_programs && make clean && cd ..
61 @rm -f NEDsim NEDsim.core *.o
8ab082d8
AT
62
63run: clean all
64 @echo ""
65 @echo "######################"
66 @echo "# Press 'q' to exit. #"
67 @echo "######################"
68 @echo ""
69 @./NEDsim