Heat the oil in a large pot over medium heat. Add the onions, salt, and several grinds of pepper and toss to combine. Reduce the heat to low and cook for about 40 minutes, stirring every few minutes, or until the onions are very soft. Increase the heat to medium and cook 15 to 20 more minutes, stirring often, until golden brown. Add the vinegar, tamari, thyme, and garlic and stir. Sprinkle the flour on the onions, stir, and cook for 2 minutes. Stir in the wine and cook 2 minutes, or until evaporated. Add the broth and simmer over medium heat for 30 minutes.