Commit 19b1c760 authored by Michael Rouse's avatar Michael Rouse

Makefile works on Linux now. Added separator directive to correctly place the...

Makefile works on Linux now. Added separator directive to correctly place the database file on Linux and Windows
parent 2b5f4e04
# Time Slime Make File
CC = gcc
CC_FLAGS = -g -Wall
CC_ENDFLAGS = -lpthread
BUILD_DIR = build
SHELL_OUT = $(BUILD_DIR)/timeslime
......@@ -17,6 +18,7 @@ ifeq ($(OS),Windows_NT)
RMDIR = cmd /C rmdir /S /Q
else
RMDIR = rmdir -f -r
CC_ENDFLAGS += -ldl
endif
.PHONY: all
......@@ -28,7 +30,7 @@ debug: all
build_executable: $(LIBRARY_SOURCES) $(LIBRARY_HEADERS) $(SHELL_SOURCES)
@$(CC) $(CC_FLAGS) $(LIBRARY_SOURCES) $(SHELL_SOURCES) -o $(SHELL_OUT)
@$(CC) $(CC_FLAGS) $(LIBRARY_SOURCES) $(SHELL_SOURCES) -o $(SHELL_OUT) $(CC_ENDFLAGS)
prep:
......
......@@ -135,6 +135,7 @@ char* args_get_directory_of_executable(char *name)
path[0] = '\0';
char read_since_last_separator[100];
read_since_last_separator[0] = '\0';
char separator;
int i;
int pos;
......@@ -143,10 +144,11 @@ char* args_get_directory_of_executable(char *name)
{
if (name[i] == '/' || name[i] == '\\')
{
separator = name[i];
if (strlen(path) > 0)
{
pos = strlen(path);
path[pos] = '\\';
path[pos] = separator;
path[pos + 1] = '\0';
}
strcat(path, read_since_last_separator);
......
......@@ -57,7 +57,8 @@ TIMESLIME_STATUS_t TimeSlime_Initialize(char directory_for_database[])
database_file_path = malloc((strlen(directory_for_database) + 1 + strlen(TIMESLIME_DATABASE_FILE_NAME)) * sizeof(char)); /* + 1 for the slash */
if (database_file_path == NULL)
return TIMESLIME_UNKOWN_ERROR;
sprintf(database_file_path, "%s\\%s", directory_for_database, TIMESLIME_DATABASE_FILE_NAME); // Append the file name
sprintf(database_file_path, "%s%s%s", directory_for_database, TIMESLIME_FILE_PATH_SEPARATOR, TIMESLIME_DATABASE_FILE_NAME); // Append the file name
// Create database if it doesn't exist
int rc;
......
......@@ -126,14 +126,21 @@ char* TimeSlime_StatusCode(TIMESLIME_STATUS_t status);
#define __TO_VERSION_STRING(v) #v
#ifdef TIMESLIME_VERSION
#undef TIMESLIME_VERSION
#undef TIMESLIME_VERSION
#endif
#define TIMESLIME_VERSION 0.8
#ifdef TIMESLIME_VERSION_STR
#undef TIMESLIME_VERSION_STR
#undef TIMESLIME_VERSION_STR
#endif
#define TIMESLIME_VERSION_STR _TO_VERSION_STRING(TIMESLIME_VERSION)
#ifndef TIMESLIME_FILE_PATH_SEPARATOR
#ifdef _WIN32
#define TIMESLIME_FILE_PATH_SEPARATOR "\\"
#else
#define TIMESLIME_FILE_PATH_SEPARATOR "/"
#endif
#endif
#endif
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment