I'm working on creating a project on a BeagleBone Green, and am struggling to get the makefile correct.
The issue is that when I run my file, my enum declaration causes an error
#include <rc/uart.h>
enum responses {
SUCCESS = 0,
SEND_ERROR,
RECEIVE_ERROR,
RESPONSE_ERROR
};
error: expected identifier before numeric constant
SUCCESS = 0,
I dug around and it seemed like it might be a preprocessor issue based on this topic, but when I toss -E into my makefile (below), it results in
gcc: warning: /usr/local/lib/test.o: linker input file unused because linking not done
I'm not sure how to set this up properly and would really appreciate some help.
This is how it's all set up:
usr
|
----include
| |
| ----rc
| | |
| | ----uart.h
| | ----time.h
| |
----lib
| |
| ----librobotcontrol.so
| |
----local
| |
| ----include
| | |
| | --- testfile.h
| |
| ----src
| | |
| | --- testfile.c
| | --- makefile
I structured the makefile after the answer here:
CC = gcc
#IDIR = /usr/include /usr/local/include
#LDIR = /usr/lib
#/usr/src /usr/local/src
SRC_DIR := /usr/local/src
OBJ_DIR := /usr/lib
BIN_DIR := .
EXE := $(BIN_DIR)/testmake
SRC := $(wildcard $(SRC_DIR)/*.c)
OBJ := $(SRC:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o), /usr/lib/librobotcontrol.so
CPPFLAGS := -Iinclude -MMD -MP
CFLAGS := -Wall
LDFLAGS := -Llib
LDLIBS := -lm
.PHONY: all
all: $(EXE)
$(EXE): $(OBJ) | $(BIN_DIR)
$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c | $(OBJ_DIR)
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
$(BIN_DIR):
mkdir -p $@
clean:
@$(RM) -rv $(BIN_DIR) $(OBJ_DIR)
-include $(OBJ:.o=.d)