aboutsummaryrefslogblamecommitdiff
path: root/Makefile
blob: bd016b7519e580557701685e4b1b48d8c03bc737 (plain) (tree)
1
2
3
4
5
6
7
8
9
10






                                                           


                                                                 









                             

                

                                                                             



                                                                                              


                                                                                                                       








                               
NAME = clak
PREFIX = $(HOME)/.local

BOARDS = mxblue quack

CC = gcc
CFLAGS += -std=c99 -Wall -Wextra -Wshadow -Werror -pedantic

BOARD_FILES = $(addsuffix /board.h,$(addprefix board/,$(BOARDS)))

ifeq ($(OS),Windows_NT)
    LDLIBS = -lWinmm
    PLATFORM = win32
else
    UNAME_S := $(shell uname)
    ifeq ($(UNAME_S),Linux)
        PLATFORM = linux
    endif
endif

default: $(NAME)

$(NAME): $(NAME).c platform/$(PLATFORM).c $(BOARD_FILES) board/boards.h
	$(CC) $(CFLAGS) $(NAME).c platform/$(PLATFORM).c $(LDLIBS) -o $(NAME)

board/boards.h:
	printf "#ifndef BOARD_DEFAULTS_H\n#define BOARD_DEFAULTS_H\n\n" > board/boards.h
	for board in $(BOARDS); do echo "#include \"$$board/board.h\"" >> board/boards.h; done
	printf "\n#define BOARDS " >> board/boards.h
	for board in $(BOARDS); do printf "BOARD(\"$$board\", board_$${board}_board_down_wav) " >> board/boards.h; done
	printf "\n\n#endif /* BOARD_DEFAULTS_H */" >> board/boards.h

$(BOARD_FILES): %.h: %_down.wav
	xxd -i "$<" "$@"

clean:
	rm -f *.o
	rm -f $(NAME)
	rm -f board/boards.h
	rm -f $(BOARD_FILES)