Last active
August 29, 2015 14:09
-
-
Save fdavidcl/7ee2e6da7120ef318116 to your computer and use it in GitHub Desktop.
Makefile for Lex programs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/************************************************* | |
Extremely helpful bit of C++ code stolen from: | |
http://cs.gmu.edu/~white/CS440/usingC++.html | |
(necessary for compilation) | |
*************************************************/ | |
#include <iostream> | |
#include <stdio.h> | |
extern FILE *yyin; | |
extern char *yytext; | |
extern int yylex(void); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################################################### | |
# Makefile | |
# Compiles Lex programs in C++ | |
############################################################################### | |
SHELL = /bin/bash | |
BIN = . | |
SRC = $(wildcard *.l) | |
EXE = $(basename $(BIN)/$(SRC)) | |
CFLAGS = -Wall -Wl,--no-as-needed | |
CXXFLAGS = $(CFLAGS) -std=c++0x | |
LDFLAGS = -ll -I/usr/include | |
############################################################################### | |
default: $(EXE) | |
$(BIN)/%: %.o help.o | |
$(CXX) -o $@ $^ $(LDFLAGS) | |
%.o: %.c | |
$(CXX) -c -x c++ $(CXXFLAGS) $< | |
%.c: %.l | |
$(LEX) -o $@ $< | |
clean: | |
$(RM) -fv $(EXE) core.* *~ *.o | |
############################################################################### |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment